#ifndef PROCESS_H
#define PROCESS_H
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include<string.h>
pid_t Fork(void)//系统调用错误处理函数
{
    pid_t pid;
    if((pid = fork())<0)
    {
        perror("fork fail");
        exit(-1);//结束进程 返回-1
    }
    return pid;
}

int Pipe(int pipefd[2])
{
    int r = pipe(pipefd);
    if(-1 == r)
    {
        perror("pipe error");
        exit(-1);//结束进程 返回-1
    }
    return  r;
}

int Mkfifo(const char *pathname, mode_t mode)
{
    int r = mkfifo(pathname,mode);
    if(-1 == r)
    {
        perror("mkfifo fail");
        exit(-1);
    }
    return r;
}

key_t Ftok(const char *pathname, int proj_id)
{
    key_t key = ftok(pathname,proj_id);
    if(-1 == key)
    {
        perror("ftok fail");
        exit(-1);
    }
}
int Open(const char *pathname, int flags)
{
    int fd=open(pathname,flags);
    if(fd==-1)
    {
        perror("open fail");
        exit(-1);
    }
}
void *Mmap(void *addr, size_t length, int prot, int flags,int fd, off_t offset)
{
    addr = mmap(addr,length,prot,flags,fd,offset);
    if(addr==MAP_FAILED)
    {
        perror("mmap fail");
        exit(-1);
    }
}
#endif